package com.alan.dfs.config;

import com.qiniu.common.Zone;
import com.qiniu.storage.BucketManager;
import com.qiniu.util.Auth;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DfsConfig {
    private static String domain = "http://ppa356so3.bkt.clouddn.com/";
    private static String accessKey = "6ZtqA6j5jHm03RBu3ozv6SIldLf0AhFEpxUXIzbH";
    private static String secretKey = "quFP5r5nOsCyP6VGd_W3iDsRe4IVBZjf40pGOI4v";

   @Bean
   public DfsRequire dfsRequire(){
       com.qiniu.storage.Configuration cfg;
       Auth auth;
       DfsRequire dfsRequire = new DfsRequire();
       dfsRequire.setDomain(domain);
       dfsRequire.setAccessKey(accessKey);
       dfsRequire.setSecretKey(secretKey);
       dfsRequire.setCfg(cfg = new com.qiniu.storage.Configuration(Zone.zone2()));
       dfsRequire.setAuth(auth = Auth.create(accessKey, secretKey));
       dfsRequire.setBucketManager(new BucketManager(auth, cfg));
       return dfsRequire;
   }
}
